
import java.util.Scanner;

public class WhileLoop
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);//使用Scanner类
        System.out.print("Enter n: ");
        long n = in.nextInt();//定义阶乘的大小*/

        if (n < 0)
        {
            System.out.print("Please input a positive number");
            return;
        }
        Factorial(n);
    }

    public static void Factorial(long n)
    {
        long wh =1;
        int i = 0;
        while(i<=n)
        {
            if(i<=1)
            {
                wh = 1;
            }
            else
            {
                wh =wh*i;
            }
            System.out.println( i + "! = " + wh);
            i++;
        }
    }
}
